home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)Z
/
(A)Z8.ADF
/
Ping
/
rnd.s
< prev
Wrap
Text File
|
1987-03-28
|
766b
|
42 lines
*\
* :ts=8
* Yet Another random number generator. By Leo Schwab.
* Based on an idea posted on the USENET (Thanks, Sam Dicker!)
* For the amiga assembler, Lattice linkage (32-bit arguments) (CS 8703.28)
*
* Calling convention:
* short rnd (range);
* short range;
*
* 8606.30
*/
xdef _rnd
section random,code
_rnd lea rndseed,a0 Get address of seed
move.l 4(sp),d1 Get range argument
tst.l d1
ble.s setseed Go reset seed
move.l (a0),d0 Get seed
add.l D0,D0
bhi.s over
eori.l #$1D872B41,D0
over
move.l d0,(a0) Save new seed
andi.l #$ffff,d0 Coerce into word
divu d1,d0 Divide by range
swap d0 and get remainder (modulus)
rts
setseed neg.w d1 Probably don't need this
move.l d1,(a0)
rts
rndseed dc.l 0
end